import wordcloud



w = ''
name = "禁言大全.txt"
with open(name,'r',encoding = 'utf-8') as f:
    w = f.read()

w = w.split()
print(w)
w = ' '.join(w)

def worcloutopng(words,size=(600,400)):
    wc = wordcloud.WordCloud(width = size[0], height = size[1],\
                            font_path = 'PingFang-W6.ttc',\
                            collocations = False,\
                            max_words = 200,)
    wc.generate(words)
    wc.to_file('{}词云.png'.format(name[:-4]))

worcloutopng(w)
print("OK!")